{php}$namespace = ns();{/php}
<script>
    Namespace.register("EBCMS.Forms");
    $(function(){
        EBCMS.Forms.FormSubmit = function FormSubmit(){
            EBCMS.CORE.submit({
                url:'{:url('user/admin.user/group')}',
                form:'{$namespace}Form',
                success:function(data){
                    EBCMS.MSG.notice('提交成功！');
                    $('#lgModal').modal('hide');
                    EBCMS.{$namespace}.refresh();
                }
            });
        };
        EBCMS.CORE.load({
            url: '{:url('user/admin.user/group')}',
            queryParams:{
                user_id:'{:input('id')}',
                __type:'group',
            },
            group:'group',
            tpl:'{$namespace}-group',
            target:'#{$namespace}-group_main',
        });
    });
</script>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">分配角色</h4>
</div>
<div class="modal-body">
    <form action="" id="{$namespace}Form">
        <div id="{$namespace}-group_main"></div>
        <input type="hidden" name="user_id" value="{:input('id')}">
    </form>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-primary" onclick="EBCMS.Forms.FormSubmit();">提交</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
<script id="{$namespace}-group" type="text/html">
    <table class="table table-bordered table-hover table-ebcms">
        <tbody>
            [[each rows as v n]]
                <tr>
                    <td>
                        <input type="checkbox" id="{$namespace}_group_item_[[v.id]]" name="group_ids[]" value="[[v.id]]" [[if v.checked]]checked[[/if]]>
                        <label for='{$namespace}_group_item_[[v.id]]'>[[v.title]]</label>
                    </td>
                </tr>
            [[/each]]
        </tbody>
    </table>
</script>